package com.health.controller;

import com.health.dto.OrderIdDTO;
import com.health.entity.Order;
import com.health.result.PageResult;
import com.health.result.Result;
import com.health.service.OrderService;
import com.health.vo.OrderIdVo;
import com.health.vo.OrderVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    //获取预约信息
    @GetMapping("/pre/info")
    public Result GetOrder(Long doctorId,Long deptId,Long patientId){
        OrderVO vo =  orderService.Order(doctorId,deptId,patientId);
        return Result.success(vo);
    }

    //提交预约
    @PostMapping
    public Result Order(@RequestBody Order order){
        OrderIdVo o = new OrderIdVo();
        o.setOrderId(orderService.save(order));
        return Result.success(o);
    }

    //获取预约详细信息
    @GetMapping
    public Result GetOrderById(Long orderId){
        OrderVO o = orderService.getById(orderId);
        return Result.success(o);
    }

    //获取预约列表
    @GetMapping("/list")
    public Result list(Long patientId,Integer page,Integer pageSize){
        List<OrderVO> list = orderService.list(patientId, page, pageSize);
        return Result.success(list);

    }

}
